package com.some;

import java.util.Scanner;

public class JingDong02 {

    public static int minChangeTimes(int[] nums, int k) {
        int time = 0;
        int num = 0;
        for (int i = 0; i < k; i++) {
            if (!(1 <= nums[i] && nums[i] <= k)) {
                time += (k - i);
            } else {
                num++;
            }
        }
        if (num == k) {
            return 0;
        }
        for (int i = k; i < nums.length; i++) {
            if (1 <= nums[i] && nums[i] <= k) {
                time += (i - k);
                num++;
                if (num == k) {
                    return time;
                }
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        System.out.println(minChangeTimes(nums, k));
    }
}
